package com.caidanxiaoyuan.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * 读取properties,版本号
 * 
 */
public class VersionConfUtil {
	private static Properties properties;
	private static Logger log = Logger.getLogger(VersionConfUtil.class);
	static{
		InputStream in = null;
		properties = new Properties();
		try {
			in = VersionConfUtil.class.getClassLoader().getResourceAsStream("version.properties");
			properties.load(in);

		} catch (FileNotFoundException ex) {
			ex.printStackTrace();
		} catch (IOException ex) {
			ex.printStackTrace();
		} finally {

			try {
				if (in != null)
					in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * 重载函数，得到key的值
	 * 
	 * @param key
	 *            取得其属性的值
	 * @return key的值
	 */
	public static String  getValue(String key) {
		if (properties.containsKey(key)) {
			// 得到某一属性的值
			String value = properties.getProperty(key);
			return value;
		} else
			return "";
	}
	

	public static void main(String[] args) {
		System.out.println(VersionConfUtil.getValue("version"));
	}

}
